-
Notifications
You must be signed in to change notification settings - Fork 55
Add config flow support #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If this PR is accepted, it paves the way for, in my opinion, a very useful feature. Currently, we can use
Using Config Flow and the appropriate Home Assistant Entity Objects, pyscript could support This Code which allows creating of such entities/devices over websocket commands for use with Node-Red should provide a good example of how this is done. |
Thanks for this PR! It looks good. Yes, there was no good reason to have the user create the pyscript directory - I saw that |
I ran
|
Fix pylint error from PR #31
@dlashua reported and I've confirmed this issue. This PR has broken the initial loading of config settings. It used to be that the
That's now
On
That might be an expensive operation, so I'm not sure whether it's ok to do that on startup. |
Thanks for the heads up @craigbarratt clearly missed some things. I actually think the way that reload is working would not work with config entries. We shouldn't be loading data from the config, we should be loading the data from the |
I actually don't understand how config flow works, and how the configuration is stored. Can you mix yaml with new-style config? The reason this is important is that just before your PR, I committed a change that allows other config parameters (below So I guess we need a way to harmonize new-style and yaml config, for both startup and reload. |
You mean can you add YAML config info in addition to setting up the config through the UI? I don't believe so unless you had a separate YAML file for the additional config items that your integration read and loaded in (e.g. outside of The way config flow works is that you define a schema for a config, and then the UI shows it to the user to fill out based on the data types -> once the user submits, the backend sees a dictionary as you would expect from a YAML config and stores that to |
So perhaps we should have a separate yaml configuration file for pyscript apps? @dlashua - what do you think? |
There is one other option - We can make it so that if a user sets up through the UI, we can import just the apps section of the config on a reload and update the config entry. I would have to think about how that should work, but it is an option. |
This change makes it possible to setup pyscript from the UI so a restart is not required (but
configuration.yaml
is still supported so there is no breaking change). I also updated the code to create the<config/path>/pyscript
folder if it doesn't exist - not sure if there was an intentional reason why you required the user to create the folder but it seemed like an easy improvement (and otherwise, the user would have to create the pyscript folder before setting the integration up in the UI).